package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ProducePlanName;
import com.ruoyi.service.IProducePlanNameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排产计划列表Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/produce_plan_name/name")
public class ProducePlanNameController extends BaseController
{
    @Autowired
    private IProducePlanNameService producePlanNameService;

    /**
     * 查询排产计划列表列表
     */
    @PreAuthorize("@ss.hasPermi('produce_plan_name:name:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProducePlanName producePlanName)
    {
        startPage();
        List<ProducePlanName> list = producePlanNameService.selectProducePlanNameList(producePlanName);
        return getDataTable(list);
    }

    /**
     * 导出排产计划列表列表
     */
    @PreAuthorize("@ss.hasPermi('produce_plan_name:name:export')")
    @Log(title = "排产计划列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProducePlanName producePlanName)
    {
        List<ProducePlanName> list = producePlanNameService.selectProducePlanNameList(producePlanName);
        ExcelUtil<ProducePlanName> util = new ExcelUtil<ProducePlanName>(ProducePlanName.class);
        util.exportExcel(response, list, "排产计划列表数据");
    }

    /**
     * 获取排产计划列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('produce_plan_name:name:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(producePlanNameService.selectProducePlanNameById(id));
    }

    /**
     * 新增排产计划列表
     */
    @PreAuthorize("@ss.hasPermi('produce_plan_name:name:add')")
    @Log(title = "排产计划列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProducePlanName producePlanName)
    {
        return toAjax(producePlanNameService.insertProducePlanName(producePlanName));
    }

    /**
     * 修改排产计划列表
     */
    @PreAuthorize("@ss.hasPermi('produce_plan_name:name:edit')")
    @Log(title = "排产计划列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProducePlanName producePlanName)
    {
        return toAjax(producePlanNameService.updateProducePlanName(producePlanName));
    }

    /**
     * 删除排产计划列表
     */
    @PreAuthorize("@ss.hasPermi('produce_plan_name:name:remove')")
    @Log(title = "排产计划列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(producePlanNameService.deleteProducePlanNameByIds(ids));
    }
}
